package EventManager;

import Gui.GameFrame;
import Gui.Dialogs.EndTurnDialog;
import Gui.Dialogs.RollDiceDialog;
import Main.Defines;

public class GameListener extends Listener
{
	/**
	 * Sets up all default messages to listen to
	 */
	public void init()
	{
		EventType newEvent = new EventType("EVENT_END_TURN");
		addEventMonitor(newEvent);
		newEvent.setName("EVENT_ROLL_DICE");
		addEventMonitor(newEvent);
	}
	/**
	 * Handles all the events related to the Game, everything except State
	 * changes and input device stuff
	 * @return true if handled event
	 */
	public boolean HandleEvent(EventType event)
	{
		if (event.getName().equals("EVENT_END_TURN"))
		{
			Defines.PLM.ChangePlayerTurn();
			// TODO check if this works right plz
			Defines.CP().setCurrentState(PlayerStates.InitialLoad.getInstance());
			EndTurnDialog showDialog = new EndTurnDialog();
			GameFrame.getInstance().update();
			return true;
		} else if (event.getName().equals("EVENT_ROLL_DICE"))
		{
			RollDiceDialog showDialog = new RollDiceDialog(GameFrame.getInstance());
			GameFrame.getInstance().update();
			return true;
		}
		return false;
	}
}
